package com.wxy.bank.servlet;

import com.wxy.bank.model.Account;
import com.wxy.bank.service.AccountService;
import com.wxy.bank.service.AccountServiceImpl;
import com.wxy.bank.util.MD5;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@javax.servlet.annotation.WebServlet("/FindAllAccountServlet")
public class FindAllAccountServlet extends javax.servlet.http.HttpServlet {
    AccountService accountService = new AccountServiceImpl();
    @Override
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        //jsp的九个内置对象  session application page pageContext exception out config
        doGet(request,response);
    }

    @Override
    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
    //acList需要传递到JSP网页上
        List<Account> acList = accountService.findAllAccount();
        request.getSession().setAttribute("alist",acList);
        //重定向(request在重定向时会丢失）
        response.sendRedirect("displayAccount.jsp");

//        request.setAttribute("alist",acList);
//        转发
//        request.getRequestDispatcher("displayAccount.jsp").forward(request,response);

    }

}